#include <bits/stdc++.h>

using namespace std;
const int maxn=50;
struct node
{
    int data;
    node* lchild;
    node* rchild;
};
int pre1[maxn],in1[maxn],n2;
node* createTreeByPreIn(int preL,int preR,int inL,int inR)
{
    if (preL>preR)
    {
        return nullptr;
    }
    node* root=new node;
    root->data=pre1[preL];
    int k;
    for (k=inL;k<=inR ;++k )
    {
        if (in1[k]==pre1[preL])
        {
            break;
        }
    }
    int numLeft=k-inL;
    root->lchild=createTreeByPreIn(preL+1,preL+numLeft,inL,k-1);
    root->rchild=createTreeByPreIn(preL+numLeft+1,preR,k+1,inR);
    return root;
}
int num10=0;
void postOrder(node* root)
{
    if (root==nullptr)
    {
        return;
    }
    postOrder(root->lchild);
    postOrder(root->rchild);
    printf("%d",root->data);
    ++num10;
    if (num10<n2)
    {
        printf(" ");
    }
}
int main_1086()
{
    scanf("%d",&n2);
    char str[5];
    stack<int> st;
    int x,preIndex=0,inIndex=0;
    for (int i=0;i<2*n2 ;++i )
    {
        scanf("%s",str);
        if (strcmp(str,"Push")==0)
        {
            scanf("%d",&x);
            pre1[preIndex++]=x;
            st.push(x);
        }
        else
        {
            in1[inIndex++]=st.top();
            st.pop();
        }
    }
    node* root =createTreeByPreIn(0,preIndex-1,0,inIndex-1);
    postOrder(root);
    return 0;
}
